# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

from cerbero.tools.libtool import LibtoolLibrary
from cerbero.utils import shell
import shutil

class Recipe(recipe.Recipe):
    name = 'libsrtp'
    version = '1.5.4'
    stype = SourceType.TARBALL
    url = 'https://github.com/cisco/%(name)s/archive/v%(version)s.tar.gz'
    licenses = [License.BSD_like]
    deps = ['openssl']
    configure_options = ' --enable-openssl '
    patches = ['libsrtp/0001-Don-t-create-a-symlink-if-there-is-no-SHAREDLIBVERSI.patch']

    files_libs = ['libsrtp']
    files_devel = ['include/srtp', 'lib/pkgconfig/libsrtp.pc']

    def prepare(self):
        # Don't accidentially build with pcap support
        self.append_env['ac_cv_lib_pcap_pcap_create'] = 'no'
        self.make += ' all shared_library'

    def install(self):
        super(Recipe, self).install()
        libdir = os.path.join(self.config.prefix,
                              'lib' + self.config.lib_suffix)
        shutil.copy(os.path.join(self.build_dir, 'srtp.def'), libdir)

    def post_install(self):
        # XXX: Don't forget to keep this in sync with the library version!
        libtool_la = LibtoolLibrary('srtp', 1, None, None, self.config.libdir,
                                    self.config.target_platform)
        libtool_la.save()
